﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class pruebas_BorrMesa : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Administrador admin = (Administrador)this.Session["Administrador"];
            if (admin == null)
            {
                Response.Redirect("noEstaLogeado.aspx", true);
            }
        ArrayList l = GestionMesas.getInstance().getMesas();
        if (l.Count == 0)
        {
            GestionMesas.getInstance().cargarMesas();
            l = GestionMesas.getInstance().getMesas();
            //Label1.Text = "Se han cargado " + l.Count + " mesas";
        }
        else
        {
            //Label1.Text = "Ya existen mesas en memoria, no se carga ninguna";
        }
        if (!Page.IsPostBack)
        {
            

            String IdMesa = Request.QueryString["IdMesa"];
            MesaBeans m = GestionMesas.getInstance().getMesa(IdMesa);
            TextBox1.Text = m.getIdMesa();
            TextBox2.Text = m.getIdJuego();
            TextBox3.Text = m.getNombreJuego();
            //TextBox5.Text = GestionMesas.getInstance().getMesa(m);
        }
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        Response.Redirect("ListarMesas.aspx");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        String IdMesa = Request.QueryString["IdMesa"];
        MesaBeans m = GestionMesas.getInstance().getMesa(IdMesa);
        GestionMesas.getInstance().borrarMesa(m);
        GestionMesas.getInstance().eliminarMesa(m);
        Response.Redirect("ListarMesas.aspx");
    }
}
